﻿/*
 * Created by SharpDevelop.
 * User: Songwut Khamsuk
 * Date: 16/6/2552
 * Time: 16:34
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;

using ICSharpCode.SharpDevelop;
using System.Xml;

namespace DreamShieldBinding
{
	/// <summary>
	/// Interaction logic for DreamShieldView.xaml
	/// </summary>
	public partial class DreamShieldView : UserControl
	{
        public virtual string SourceFile { get; protected set; }

        /// <summary>
        /// XmlDocument of the project
        /// </summary>
        protected virtual XmlDocument XmlFile { get; set; }

        /// <summary>
        /// Object representation of the project
        /// </summary>
        public virtual DSXProject XmlProject { get; protected set; }
		
		public DreamShieldView(string file)
		{
			InitializeComponent();
			
			SourceFile = file;

            XmlFile = new XmlDocument();
            XmlFile.Load(file);

            var root = XmlFile.SelectSingleNode("DreamShieldProject");
            if (root == null)
            {
                /* new project */
                XmlProject = new DSXProject();
                XmlFile.AppendChild(XmlProject.ProjectRoot);
            }
            else
            {
                XmlProject = new DSXProject(root);
            }

            LoadTree();
		}

        protected virtual void LoadTree()
        {
            leftTree.Items.Add("Project");
            leftTree.Items.Add("Product");
            leftTree.Items.Add("Texts");
            leftTree.Items.Add("Files");
            leftTree.Items.Add("Compiler");
        }
    }
}